﻿<?php
ignore_user_abort(TRUE);
require_once("./interface.php");
require_once("./utils.php");
require_once("./interface.php");
require_once("./TechnicFunc.php");
require_once("./SoldierFunc.php");
require_once("./HotelFunc.php");
require_once("./OfficeFunc.php");
require_once("./MarketFunc.php");
require_once("./UnionFunc.php");
require_once("./StoreFunc.php");
require_once("./TroopFunc.php");
require_once("./global.php");
require_once("./report.php");
require_once("./bin_ss.php");
require_once("./bin_rank.php");


function zhenchaInfo($troop)
{
	//先写不战斗的侦查
	$tid = $troop['id'];

	$uid = $troop['uid'];

	$h_battleid=0;

	sql_query("update sys_troops set state=1,starttime=unix_timestamp(),endtime=unix_timestamp()+`pathtime` where id='$tid'");
	
	$title = 5;

	$origincid = $troop['cid'];

	$happencid = $troop['targetcid'];
	$city_name=sql_fetch_one_cell("select name from sys_city where cid='$happencid'");

	//读出被侦查对象的军队信息
    $jundui = sql_fetch_into_arrays("select * from sys_city_soldier where cid='$happencid'&&count!=0 order by sid");// 读取守兵数量，全部读出
    $i=0;
	$jundui_content="";
	while($jundui['sid'][$i]!="")
	{
		    $jundui_s_id=$jundui['sid'][$i];
		    $cfg_soldier_name=sql_fetch_into_arrays("select * from cfg_soldier where sid='$jundui_s_id'");
			$jundui_s_name=$cfg_soldier_name['name'][0];
			$jundui_content=$jundui_content."<tr>
    <td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$jundui_s_name."</p></td>
    <td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$jundui['count'][$i]."</p></td>
  </tr>";
			$i=$i+1;
	}
  $jundui_c_table="<table width='220' border='1' cellspacing='0' cellpadding='0' bordercolor='#999999'><tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>军队</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>数量</p></td></tr>";


   //读出被侦查对象的城防信息
   $city_defence= sql_fetch_into_arrays("select * from sys_city_defence where cid='$happencid'&&count!=0 order by did"); //读取城防数量，暂时不考虑科技等，全部读出
   $k=0;
   $city_defence_content="";   
   while($city_defence['did'][$k]!="")
	{
		    $city_defence_id=$city_defence['did'][$k];
		    $cfg_defence_name=sql_fetch_into_arrays("select * from cfg_defence where did='$city_defence_id'");
			$city_d_name=$cfg_defence_name['name'][0];
			$city_defence_content=$city_defence_content."<tr>
    <td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$city_d_name."</p></td>
    <td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$city_defence['count'][$k]."</p></td>
  </tr>";
			$k=$k+1;
	}
  $city_defence_table="<table width='220' border='1' cellspacing='0' cellpadding='0' bordercolor='#999999'><tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>城防</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>数量</p></td></tr>";

   //读出被侦查对象的将领信息

   $has_heros=sql_fetch_into_arrays("select * from sys_city_hero  where cid='$happencid' order by level desc");
   $g=0;
   $has_herose_content="";   
   while($has_heros['name'][$g]!="")
	{
			$heros_name=$has_heros['name'][$g];
			$heros_level=$has_heros['level'][$g];
			$heros_loyalty=$has_heros['loyalty'][$g];
			$has_heros_content=$has_heros_content."<tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size:12px'>".$heros_name."</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$heros_level."</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$heros_loyalty."</p></td></tr>";
			$g=$g+1;
	}
  $has_heros_table="<table width='220' border='1' cellspacing='0' cellpadding='0' bordercolor='#999999'><tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>将领</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>等级</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>忠诚</p></td></tr>";





   //读出被侦查对象的城外资源信息
   $cwzy=sql_fetch_one("select * from mem_city_resource where cid='$happencid'"); //读取资源
   $cwzy_content="<table width='220' border='1' cellspacing='0' cellpadding='0' bordercolor='#999999'><tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>城外资源</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>数量</p></td> </tr><tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>粮食</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$cwzy['food']."</p></td></tr><tr><td width='90' height='23' align='center'>木材</td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$cwzy['wood']."</p></td></tr><tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>石料</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$cwzy['rock']."</p></td></tr><tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>铁锭</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$cwzy['iron']."</p></td></tr></table>";

   //读出被侦查对象的城外建筑信息
   $cwjz=sql_fetch_into_arrays("SELECT DISTINCT bid from sys_building where cid='$happencid'&&bid<='4' order by bid"); //读取建筑信息
   $cwjz_h=sql_fetch_into_arrays("SELECT * from sys_building where cid='$happencid'&&bid<='4'"); 
   $j=0;

   $cwjz_content="";
   while($cwjz['bid'][$j]!="")
	   {  

	  $h=0;
	  $cwjz_bid=$cwjz['bid'][$j];
      $cwjz_1=sql_fetch_into_arrays("select * from sys_building where cid='$happencid'&&bid='$cwjz_bid' order by level desc");
   $cwjz_level_b="";
   $cwjz_level_c="";
      while($cwjz_1['bid'][$h]!="")
		  {
	     if($h>28)
			 $cwjz_level_b=$cwjz_1['level'][$h].",&nbsp;".$cwjz_level_b;
		else
		  $cwjz_level_c=$cwjz_1['level'][$h].",&nbsp;".$cwjz_level_c;
		
        $h=$h+1;
	  }

	 $cwjz_name=sql_fetch_one_cell("select name from cfg_building where bid='$cwjz_bid'");
	 $cwjz_content=$cwjz_content."<tr>
    <td width='100' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$cwjz_name."</p></td><td width='480' height='23' ><p style='color: #33FF00; font-size: 12px'>".$cwjz_level_c.$cwjz_level_b."</p></td></tr>";
    $j=$j+1;
   }

  $cwjz_table="<table width='580' border='1' cellspacing='0' cellpadding='0' bordercolor='#999999'><tr><td width='100' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>城外建筑</p></td><td width='480' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>等级</p></td></tr>";





   //读出被侦查对象的城内资源信息
   $cnzy=sql_fetch_one("select * from mem_city_resource where cid='$happencid'"); //读取资源
   $cnzy_content="<table width='220' border='1' cellspacing='0' cellpadding='0' bordercolor='#999999'><tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>城内资源</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>数量</p></td> </tr><tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>民心</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$cwzy['morale']."</p></td></tr><tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>人口</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$cwzy['people']."</p></td></tr><tr><td width='90' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>黄金</p></td><td width='130' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$cwzy['gold']."</p></td></tr></table>";

   //读出被侦查对象的城内建筑信息
   $cnjz=sql_fetch_into_arrays("SELECT DISTINCT bid from sys_building where cid='$happencid'&&bid>'4' order by bid"); //读取建筑信息
   $cnjz_h=sql_fetch_into_arrays("SELECT * from sys_building where cid='$happencid'&&bid>'4'"); 
   $m=0;
   $cnjz_content="";
   while($cnjz['bid'][$m]!="")
	   {  
	  $n=0;
	  $cnjz_bid=$cnjz['bid'][$m];
      $cnjz_1=sql_fetch_into_arrays("select * from sys_building where cid='$happencid'&&bid='$cnjz_bid' order by level desc");
   $cnjz_level_c="";
      while($cnjz_1['bid'][$n]!="")
		  {
	    $cnjz_level_c=$cnjz_1['level'][$n].",&nbsp;".$cnjz_level_c;
		
        $n=$n+1;
	  }
	 $cnjz_name=sql_fetch_one_cell("select name from cfg_building where bid='$cnjz_bid'");
	 $cnjz_content=$cnjz_content."<tr><td width='100' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>".$cnjz_name."</p></td><td width='480' height='23' ><p style='color: #33FF00; font-size: 12px'>".$cnjz_level_c."</p></td></tr>";
     $m=$m+1;
   }

  $cnjz_table="<table width='580' border='1' cellspacing='0' cellpadding='0' bordercolor='#999999'><tr><td width='100' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>城外建筑</p></td><td width='480' height='23' align='center'><p style='color: #33FF00; font-size: 12px'>等级</p></td></tr>";


  //侦查报告内容集合
   $content="向".$city_name.getPosition($happencid)."执行侦察任务的军队已到达目标.对方未发觉。<br> 
   侦察报告:<br>".$cwzy_content."<br><br>".$cwjz_table.$cwjz_content."</td></tr></table>"."<br><br>".$cnzy_content."<br><br>".$cnjz_table.$cnjz_content."</td></tr></table>"."<br><br>".$city_defence_table.$city_defence_content."</td></tr></table>"."<br><br>".$jundui_c_table.$jundui_content."</td></tr></table>"."<br><br>".$has_heros_table.$has_heros_content."</td></tr></table>";

        sendReport($uid,0,$title,$origincid,$happencid,$h_battleid,$content);



}

 

?>